package disjunction
{
	import disjunction.GameState;
	import disjunction.View;
	import disjunction.state.StateChangeEvent;
	import disjunction.timing.SimulationTimer;
	
	import flash.events.TimerEvent;

	/**
	 * The Controller in the context of the (MVC) GameState. Provides a configurable
	 * base for timing and updates. Actual control logic is handled through injected
	 * strategies.
	 * 
	 * @author Nick Wiggill
	 */

	public class Controller extends TimedUpdater
	{
		/** 
		 * The model pertaining to this Controller. Since only the parent controller
		 * has a reference to this, there is no problem with it being public.
		 */
		public var model:Object;
		public var view:View;
		
		//(Using superconstructor as default)
		
		/**
		 * (abstract) Initialise the controller and model given appropriate data. The data
		 * may either be copied directly from the initialisation information, or it may be
		 * derived. (For this reason we do initialisation in the controller; there may
		 * be a great deal of logic involved in deriving from initialisation data.
		 * @param config The configuration for the controller itself. Typically describes 
		 * the rate at which various aspects of the model execute.
		 * @param modelParameters A set of values used to create the model.
		 */
		public function initialise_(config:ControllerConfig):void
		{
			super.initialiseTiming(config as TimingConfig);

			trace('calling controller to initialise');
			initialise(config); //subclass (user) initialisation

			if (isRealTime)
				start();
		}
		
		/** (abstract) */
		public function initialise(data:Object):void
		{
		}
		
	}
}